const DB = require('../db/index');
const enumData = require('../enumeration/index');
const exception = require('../exception');

module.exports = {
    create(data, successFn, failFn) {
        try {
            DB.AlarmNoticeRecord.create(data).then((res) => {
                successFn({code: 0,data:res})
            });
        } catch (e) {
            failFn(exception.ex(e))
        }
    },
    update(data, successFn, failFn) {
        try {
            DB.AlarmNoticeRecord.update(data).then(() => {
                successFn({code: 0})
            });
        } catch (e) {
            failFn(exception.ex(e))
        }
    },
    search(data, successFn, failFn) {
        try {
            DB.AlarmNoticeRecord.searchAll(data).then((res) => {
                successFn({
                    code: 0, data: res
                });
            });
        } catch (e) {
            failFn(exception.ex(e))
        }
    },
    delete(data, successFn, failFn) {
        try {
            DB.AlarmNoticeRecord.delete({id: data.id}).then(() => {
                successFn({code: 0})
            });
        } catch (e) {
            failFn(exception.ex(e))
        }
    }
};
